﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Data;
using System.Data.SqlClient;
using System.Collections;

namespace B2B.Models
{
    public class SP_ThanhVien
    {

        private int maTV;
        public int MaTV
        {
            get { return maTV; }
        }

        private string email;
        public string Email
        {
            get { return Email; }
            set { Email = value; }
        }

        private string password;
        public string Password
        {
            get { return Password; }
            set { Password = value; }
        }

        private int maQuocGia;
        public int MaQuocGia
        {
            get { return MaQuocGia; }
            set { MaQuocGia = value; }
        }

        private int maTinh;
        public int MaTinh
        {
            get { return MaTinh; }
            set { MaTinh = value; }
        }

        private string hoTen;
        public string HoTen
        {
            get { return HoTen; }
            set { HoTen = value; }
        }

        private string tenCongTy;
        public string TenCongTy
        {
            get { return TenCongTy; }
            set { TenCongTy = value; }
        }

        private string soDT;
        public string SoDT
        {
            get { return SoDT; }
            set { SoDT = value; }
        }

        private string diaChiCongTy;
        public string DiaChiCongTy
        {
            get {return DiaChiCongTy;}
            set { DiaChiCongTy = value; }
        }

        private int namThanhLap;
        public int NamThanhLap
        {
            get { return NamThanhLap; }
            set { NamThanhLap = value; }
        }

        private string webSite;
        public string website
        {
            get { return website; }
            set { website = value; }
        }

        private string quyMo;
        public string QuyMo
        {
            get { return QuyMo; }
            set { QuyMo = value; }
        }

        private string diaChiNhaMay;
        public string DiaChiNhaMay
        {
            get { return DiaChiNhaMay; }
            set { DiaChiNhaMay = value; }
        }
        private string hinhAnh;
        public string HinhAnh
        {
            get { return HinhAnh; }
            set { HinhAnh = value; }
        }
        private string gioiThieu;
        public string GioiThieu
        {
            get { return GioiThieu; }
            set { GioiThieu = value; }
        }
        private int maLoaiTV;
        public int MaLoaiTV
        {
            get { return MaLoaiTV; }
            set { MaLoaiTV = value; }
        }

        private int tinhTrangTV;
        public int TinhTrangTV
        {
            get { return TinhTrangTV; }
            set { TinhTrangTV = value; }
        }
        private bool laTV;
        public bool LaTV
        {
            get { return LaTV; }
            set { LaTV = value; }
        }

        private DateTime ngayBatDau;
        public DateTime NgayBatDau
        {
            get { return NgayBatDau; }
            set { NgayBatDau = value; }
        }
        private DateTime ngayKetThuc;
        public DateTime NgayKetThuc
        {
            get { return NgayKetThuc; }
            set { NgayKetThuc = value; }
        }
        

        public ArrayList ThanhVien()
        {
            ArrayList list_ThanhVien = new ArrayList();
            SqlConnection conn = KetNoi.Connection();
            SqlCommand cmd = new SqlCommand("SP_THANHVIEN", conn);

            cmd.CommandType = CommandType.StoredProcedure;
            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                SP_ThanhVien sp = new SP_ThanhVien();
                sp.MaTV = int.Parse(reader.GetDecimal(0).ToString());
                sp.Email = reader.GetString(1);
                sp.Password = reader.GetString(2);
                sp.MaQuocGia = int.Parse(reader.GetDecimal(3).ToString());
                sp.MaTinh = int.Parse(reader.GetDecimal(4).ToString());
                sp.HoTen = reader.GetString(5);
                sp.TenCongTy = reader.GetString(6);
                sp.SoDT = reader.GetString(7);
                sp.DiaChiCongTy = reader.GetString(8);
                sp.NamThanhLap = int.Parse(reader.GetDecimal(9).ToString());
                sp.website = reader.GetString(10);
                sp.QuyMo = reader.GetString(11);
                sp.DiaChiNhaMay = reader.GetString(12);
                sp.QuyMoNhaMay = reader.GetString(13);
                sp.HinhAnh = reader.GetString(14);
                sp.GioiThieu = reader.GetString(15);
                sp.MaLoaiTV = int.Parse(reader.GetDecimal(16).ToString());
                sp.TinhTrang = int.Parse(reader.GetDecimal(17).ToString());
                sp.LaTV = reader.GetString(18);
                sp.NgayBatDau = reader.GetDateTime(19);
                sp.NgayKetThuc = reader.GetDateTime(20);
                list_TaiKhoan.Add(sp);
                
            }
            conn.Close();
            return list_TaiKhoan;
        }
       
    }
}